
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rotempco.Core.ORM.ADAL;
using System.Data.SqlClient;
using Rotempco.BaseClass.Objects.EntityObjects;
using Rotempco.Core.ORM.Objects;
using Rotempco.Core.ORM.Objects.Enums;
using Rotempco.Core.ORM.Logic;
using Rotempco.Core.Logic;




namespace Rotempco.BaseClass.DAL
{
    public partial class PasswordHistoryData : ADAL<PasswordHistory, long>
    {
	    #region [ ADATA Implementation ]

        protected override string GetTableName()
        {
            return "PasswordHistory";
        }

        protected override Pair<string, string> GetIdentity()
        {
            return new Pair<string, string>("PasswordHistoryId", SymbolExtensions.GetPropertyName((PasswordHistory d) => d.PasswordHistoryId));
        }

        protected override List<ORMParameter> GetORMMapping()
        {
            List<ORMParameter> mapping = new List<ORMParameter>();
		
			mapping.Add(new ORMParameter("LoginUserId", SymbolExtensions.GetPropertyPair((PasswordHistory d) => d.LoginUserId)));
			mapping.Add(new ORMParameter("PasswordHash", SymbolExtensions.GetPropertyPair((PasswordHistory d) => d.PasswordHash)));
			mapping.Add(new ORMParameter("CreatedDate", SymbolExtensions.GetPropertyPair((PasswordHistory d) => d.CreatedDate)));

            return mapping;
        }

        #endregion

        #region [ GetBy ]

        public PasswordHistory GetSingle(bool getDeleted = false, long? passwordHistoryId = null, long? loginUserId = null, string passwordHash = null, DateTime? createdDate = null )
        {
            List<PropertyPair> parameterList = GetByParameterList(passwordHistoryId: passwordHistoryId, loginUserId: loginUserId, passwordHash: passwordHash, createdDate: createdDate);
            List<NullablePair> nullablePairList = GetNullablePairList();
            return GetBy(parameterList, getDeleted, nullablePairList: nullablePairList).SingleOrDefault();
        }

        public List<PasswordHistory> GetList(bool getDeleted = false, long? getFirstEntries = null, long? getLastEntries = null, long? passwordHistoryId = null, long? loginUserId = null, string passwordHash = null, DateTime? createdDate = null )
        {
            List<PropertyPair> parameterList = GetByParameterList(passwordHistoryId: passwordHistoryId, loginUserId: loginUserId, passwordHash: passwordHash, createdDate: createdDate);
            List<NullablePair> nullablePairList = GetNullablePairList();
            return GetBy(parameterList, getDeleted, getFirstEntries, getLastEntries, nullablePairList: nullablePairList);
        }

        #endregion

        #region [ Private ]

        private List<PropertyPair> GetByParameterList(long? passwordHistoryId = null, long? loginUserId = null, string passwordHash = null, DateTime? createdDate = null)
        {
            List<PropertyPair> mapping = new List<PropertyPair>();

			mapping.Add(new PropertyPair(passwordHistoryId, SymbolExtensions.GetPropertyPair((PasswordHistory d) => d.PasswordHistoryId)));
			mapping.Add(new PropertyPair(loginUserId, SymbolExtensions.GetPropertyPair((PasswordHistory d) => d.LoginUserId)));
			mapping.Add(new PropertyPair(passwordHash, SymbolExtensions.GetPropertyPair((PasswordHistory d) => d.PasswordHash)));
			mapping.Add(new PropertyPair(createdDate, SymbolExtensions.GetPropertyPair((PasswordHistory d) => d.CreatedDate)));

            return mapping;
        }

        private List<NullablePair> GetNullablePairList()
        {
            List<NullablePair> nullablePairList = new List<NullablePair>();



            if (nullablePairList.Count <= 0)
                return null;

            return nullablePairList;
        }

        #endregion

	}
}

